<script type="text/javascript">
	$j("#list_pathologypatient").jqGrid({
		url:'pathologypatient/list/<?php echo $parameters["id_patient"];?>',
		datatype:'json',
		mtype:'POST',
		colNames:['Patología', 'Presente Actualmente', 'Desde Hace [años]', 'Heredado','Paciente'],
		colModel:[
		          {
			          name:'pathology_id',
			          index:'pathology_id', 
			          width:30, 
			          editable: true,
			          edittype: 'select',
			          editoptions: {
			          	value:{
			          		<?php
			          		 	
			          		 $pathologies = $parameters["pathologies"];				          			 
					  		 $count = count($pathologies);
					  		 for ($i = 0; $i < $count; $i++){
					  		 	echo $pathologies[$i]->id.":'".$pathologies[$i]->pathology_name."'";
					  		 	if (($i+1) < $count) echo ",";
					  		 	else echo "";
					  		 }
						    ?>
			          	}
			          }
			      },
			      {
			          name:'currently',
			          index:'currently',
			          width:20, 
			          editable: true,
			          edittype: 'checkbox',
			          formatter: 'checkbox',
			          editoptions: {value: "1:0"},
			          align: "center"
			      },
		          {
			          name:'age_at_start',
			          index:'age_at_start',
			          width:15, 
			          editable: true,
			          align:"right"
			      },
		          {
			          name:'inherited', 
			          index:'inherited', 
			          width:10,
			          editable: true,
			          edittype: 'checkbox',
			          formatter: 'checkbox',
			          editoptions: {value: "1:0"},
			          align:"center"
			      },
			      {
				      name: 'patient_id',
				      index: 'patient_id',
				      edittype: 'text',
				      editoptions: {value: <?php echo $parameters["id_patient"]; //esto debera cambiarse?>},
				      width: 10,
				      editable: true,
				      hidden: true
				   }
		],
		pager:'#gridpager_pathologypatient',
		loadtext: 'Cargando Patologías del Paciente ...',
		rowNum:10,
		rowList:[10],
		sortname:'pathology_id',
		sortorder:'asc',
		autowidth:true,
		viewrecords:true,
		onSelectRow:function(id){},
		editurl:'pathologypatient/save/<?php echo $parameters["id_patient"];?>',
		scrollOffset:0
	});

	$j("#list_pathologypatient").setGridWidth("650",true);
	$j("#list_pathologypatient").setGridHeight(220);
	
	$j("#list_pathologypatient").jqGrid('navGrid','#gridpager_pathologypatient',{
			edit:true,
			add:true,
			del:true,
			search:true},
			{
				width: 350,
				closeAfterEdit:true,
				editCaption: "Modificar Patología de Paciente"
			},
			{
				width: 350,
				closeAfterAdd:true,
				addCaption: "Nueva Patología de Paciente"
			},
			{
				msg: "¿Desea eliminar la patología seleccionada del paciente?",
				caption: "Eliminar Patología de Paciente",
				width:350
			});
</script>
